<template>
	<view class="checkbox">
		<checkbox-group @change="switchStatus(listItem)">
			<label><checkbox :checked="listItem.isChoose" /></label>
		</checkbox-group>
	</view>
</template>

<script>
	import {mapState,mapMutations} from 'vuex'
export default {
	mounted() {},
	data() {
		return {
		};
	},
	props: {
		listItem: {
			type: Object,
			default: () => {}
		}
	},
	computed:{
		...mapState(["list"]),
	},
	methods: {
		// ...mapMutations(["updateListItem"]),
		switchStatus(item) {
			this.$set(item,"isChoose",!item.isChoose)
			const targetIndex=this.list.findIndex(listItem=>{
				return item.id===listItem.id
			})
			//一定要通过这种方式更新数据才有效？
			this.$set(this.list,targetIndex,item)
		}
	},
	watch: {}
};
</script>

<style lang="less"></style>
